<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.7"/>
<title>AES-API: E:/Other/Gitee/components-examples/A01-AES/exam/aes/aes.c 文件参考</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
  $(document).ready(initResizable);
  $(window).load(resizeHeight);
</script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
  $(document).ready(function() { searchBox.OnSelectItem(0); });
</script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectlogo"><img alt="Logo" src="gzh (2).jpg"/></td>
  <td style="padding-left: 0.5em;">
   <div id="projectname">AES-API
   &#160;<span id="projectnumber">V1.0.0</span>
   </div>
   <div id="projectbrief">AES-API</div>
  </td>
   <td>        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <img id="MSearchSelect" src="search/mag_sel.png"
               onmouseover="return searchBox.OnSearchSelectShow()"
               onmouseout="return searchBox.OnSearchSelectHide()"
               alt=""/>
          <input type="text" id="MSearchField" value="搜索" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
          </span>
        </div>
</td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- 制作者 Doxygen 1.8.7 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'搜索');
</script>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
$(document).ready(function(){initNavTree('aes_8c.html','');});
</script>
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
<a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark">&#160;</span>全部</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark">&#160;</span>文件</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark">&#160;</span>函数</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark">&#160;</span>变量</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark">&#160;</span>宏定义</a></div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div class="header">
  <div class="summary">
<a href="#func-members">函数</a> &#124;
<a href="#var-members">变量</a>  </div>
  <div class="headertitle">
<div class="title">aes.c 文件参考</div>  </div>
</div><!--header-->
<div class="contents">
<div class="textblock"><code>#include &quot;<a class="el" href="aes_8h_source.html">aes.h</a>&quot;</code><br />
<code>#include &quot;<a class="el" href="gmult_8h_source.html">gmult.h</a>&quot;</code><br />
</div><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="func-members"></a>
函数</h2></td></tr>
<tr class="memitem:a2a81402428c8f2be48e0cc40454164a0"><td class="memItemLeft" align="right" valign="top">uint8_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="aes_8c.html#a2a81402428c8f2be48e0cc40454164a0">gadd</a> (uint8_t a, uint8_t b)</td></tr>
<tr class="memdesc:a2a81402428c8f2be48e0cc40454164a0"><td class="mdescLeft">&#160;</td><td class="mdescRight">Addition in GF(2^8)  <a href="#a2a81402428c8f2be48e0cc40454164a0">更多...</a><br /></td></tr>
<tr class="separator:a2a81402428c8f2be48e0cc40454164a0"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a589f455f9e9215c4328dd53f755bc839"><td class="memItemLeft" align="right" valign="top">uint8_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="aes_8c.html#a589f455f9e9215c4328dd53f755bc839">gsub</a> (uint8_t a, uint8_t b)</td></tr>
<tr class="memdesc:a589f455f9e9215c4328dd53f755bc839"><td class="mdescLeft">&#160;</td><td class="mdescRight">Subtraction in GF(2^8)  <a href="#a589f455f9e9215c4328dd53f755bc839">更多...</a><br /></td></tr>
<tr class="separator:a589f455f9e9215c4328dd53f755bc839"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a4fd78e9e70a8fa25ffe7ac89c18d31a3"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="aes_8c.html#a4fd78e9e70a8fa25ffe7ac89c18d31a3">coef_add</a> (uint8_t a[], uint8_t b[], uint8_t d[])</td></tr>
<tr class="memdesc:a4fd78e9e70a8fa25ffe7ac89c18d31a3"><td class="mdescLeft">&#160;</td><td class="mdescRight">Addition of 4 byte words.  <a href="#a4fd78e9e70a8fa25ffe7ac89c18d31a3">更多...</a><br /></td></tr>
<tr class="separator:a4fd78e9e70a8fa25ffe7ac89c18d31a3"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a04aedb6d0c8e24c05e0f0ae089874229"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="aes_8c.html#a04aedb6d0c8e24c05e0f0ae089874229">coef_mult</a> (uint8_t *a, uint8_t *b, uint8_t *d)</td></tr>
<tr class="separator:a04aedb6d0c8e24c05e0f0ae089874229"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a1ce5ff75f809a1788aa380e8a5c43bf2"><td class="memItemLeft" align="right" valign="top">uint8_t *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="aes_8c.html#a1ce5ff75f809a1788aa380e8a5c43bf2">Rcon</a> (uint8_t i)</td></tr>
<tr class="separator:a1ce5ff75f809a1788aa380e8a5c43bf2"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a3647794630b190782fc19e3d9b2be035"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="aes_8c.html#a3647794630b190782fc19e3d9b2be035">add_round_key</a> (uint8_t *state, uint8_t *w, uint8_t r)</td></tr>
<tr class="separator:a3647794630b190782fc19e3d9b2be035"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:adb11e39050fc05e4546c825ca68d6eae"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="aes_8c.html#adb11e39050fc05e4546c825ca68d6eae">mix_columns</a> (uint8_t *state)</td></tr>
<tr class="memdesc:adb11e39050fc05e4546c825ca68d6eae"><td class="mdescLeft">&#160;</td><td class="mdescRight">列混合变换  <a href="#adb11e39050fc05e4546c825ca68d6eae">更多...</a><br /></td></tr>
<tr class="separator:adb11e39050fc05e4546c825ca68d6eae"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a4f1588573568532d6eee4ab5bab3da05"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="aes_8c.html#a4f1588573568532d6eee4ab5bab3da05">inv_mix_columns</a> (uint8_t *state)</td></tr>
<tr class="memdesc:a4f1588573568532d6eee4ab5bab3da05"><td class="mdescLeft">&#160;</td><td class="mdescRight">逆列混合变换  <a href="#a4f1588573568532d6eee4ab5bab3da05">更多...</a><br /></td></tr>
<tr class="separator:a4f1588573568532d6eee4ab5bab3da05"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a8887303a86f47615327ccb6ec6832bad"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="aes_8c.html#a8887303a86f47615327ccb6ec6832bad">shift_rows</a> (uint8_t *state)</td></tr>
<tr class="memdesc:a8887303a86f47615327ccb6ec6832bad"><td class="mdescLeft">&#160;</td><td class="mdescRight">行移位变换  <a href="#a8887303a86f47615327ccb6ec6832bad">更多...</a><br /></td></tr>
<tr class="separator:a8887303a86f47615327ccb6ec6832bad"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a600ebfd9163919a2224440fc627bc659"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="aes_8c.html#a600ebfd9163919a2224440fc627bc659">inv_shift_rows</a> (uint8_t *state)</td></tr>
<tr class="memdesc:a600ebfd9163919a2224440fc627bc659"><td class="mdescLeft">&#160;</td><td class="mdescRight">逆行移位变换  <a href="#a600ebfd9163919a2224440fc627bc659">更多...</a><br /></td></tr>
<tr class="separator:a600ebfd9163919a2224440fc627bc659"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a26eb58cd12585e4469b85fe2c07d7e43"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="aes_8c.html#a26eb58cd12585e4469b85fe2c07d7e43">sub_bytes</a> (uint8_t *state)</td></tr>
<tr class="memdesc:a26eb58cd12585e4469b85fe2c07d7e43"><td class="mdescLeft">&#160;</td><td class="mdescRight">字节替换  <a href="#a26eb58cd12585e4469b85fe2c07d7e43">更多...</a><br /></td></tr>
<tr class="separator:a26eb58cd12585e4469b85fe2c07d7e43"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a159a659a54feeb3f10ea6b9b458da4a3"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="aes_8c.html#a159a659a54feeb3f10ea6b9b458da4a3">inv_sub_bytes</a> (uint8_t *state)</td></tr>
<tr class="memdesc:a159a659a54feeb3f10ea6b9b458da4a3"><td class="mdescLeft">&#160;</td><td class="mdescRight">逆字节替代变换  <a href="#a159a659a54feeb3f10ea6b9b458da4a3">更多...</a><br /></td></tr>
<tr class="separator:a159a659a54feeb3f10ea6b9b458da4a3"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a95c2f223af5c7bc9e20b501fa4c026e3"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="aes_8c.html#a95c2f223af5c7bc9e20b501fa4c026e3">sub_word</a> (uint8_t *w)</td></tr>
<tr class="memdesc:a95c2f223af5c7bc9e20b501fa4c026e3"><td class="mdescLeft">&#160;</td><td class="mdescRight">对于 4 字节中的每一字节分别应用 S 盒  <a href="#a95c2f223af5c7bc9e20b501fa4c026e3">更多...</a><br /></td></tr>
<tr class="separator:a95c2f223af5c7bc9e20b501fa4c026e3"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a65c0ad6a1eef16ffa1c54cb0cb03f9b0"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="aes_8c.html#a65c0ad6a1eef16ffa1c54cb0cb03f9b0">rot_word</a> (uint8_t *w)</td></tr>
<tr class="memdesc:a65c0ad6a1eef16ffa1c54cb0cb03f9b0"><td class="mdescLeft">&#160;</td><td class="mdescRight">对 4-byte 字进行循环移位  <a href="#a65c0ad6a1eef16ffa1c54cb0cb03f9b0">更多...</a><br /></td></tr>
<tr class="separator:a65c0ad6a1eef16ffa1c54cb0cb03f9b0"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a461739b060263bfe2888f4a47d8f5186"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="aes_8c.html#a461739b060263bfe2888f4a47d8f5186">aes_key_expansion</a> (uint8_t *key, uint8_t *w)</td></tr>
<tr class="memdesc:a461739b060263bfe2888f4a47d8f5186"><td class="mdescLeft">&#160;</td><td class="mdescRight">Key Expansion.  <a href="#a461739b060263bfe2888f4a47d8f5186">更多...</a><br /></td></tr>
<tr class="separator:a461739b060263bfe2888f4a47d8f5186"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a5682ceb1811499fe30fbe705877ff32c"><td class="memItemLeft" align="right" valign="top">uint8_t *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="aes_8c.html#a5682ceb1811499fe30fbe705877ff32c">aes_init</a> (size_t key_size)</td></tr>
<tr class="memdesc:a5682ceb1811499fe30fbe705877ff32c"><td class="mdescLeft">&#160;</td><td class="mdescRight">Initialize AES variables and allocate memory for expanded key.  <a href="#a5682ceb1811499fe30fbe705877ff32c">更多...</a><br /></td></tr>
<tr class="separator:a5682ceb1811499fe30fbe705877ff32c"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a5d8ac3ac83810baa35fa15c5e4b25303"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="aes_8c.html#a5d8ac3ac83810baa35fa15c5e4b25303">aes_cipher</a> (uint8_t *in, uint8_t *out, uint8_t *w)</td></tr>
<tr class="memdesc:a5d8ac3ac83810baa35fa15c5e4b25303"><td class="mdescLeft">&#160;</td><td class="mdescRight">Performs the AES cipher operation.  <a href="#a5d8ac3ac83810baa35fa15c5e4b25303">更多...</a><br /></td></tr>
<tr class="separator:a5d8ac3ac83810baa35fa15c5e4b25303"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a73d0f24db5e8c95eaf2b6c1979188b50"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="aes_8c.html#a73d0f24db5e8c95eaf2b6c1979188b50">aes_inv_cipher</a> (uint8_t *in, uint8_t *out, uint8_t *w)</td></tr>
<tr class="memdesc:a73d0f24db5e8c95eaf2b6c1979188b50"><td class="mdescLeft">&#160;</td><td class="mdescRight">Performs the AES inverse cipher operation.  <a href="#a73d0f24db5e8c95eaf2b6c1979188b50">更多...</a><br /></td></tr>
<tr class="separator:a73d0f24db5e8c95eaf2b6c1979188b50"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="var-members"></a>
变量</h2></td></tr>
<tr class="memitem:a2689c4b3931025b79053532a5f1b0a85"><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="aes_8c.html#a2689c4b3931025b79053532a5f1b0a85">K</a></td></tr>
<tr class="memdesc:a2689c4b3931025b79053532a5f1b0a85"><td class="mdescLeft">&#160;</td><td class="mdescRight">密码所使用的秘密密钥.  <a href="#a2689c4b3931025b79053532a5f1b0a85">更多...</a><br /></td></tr>
<tr class="separator:a2689c4b3931025b79053532a5f1b0a85"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:afcfa24a6132fa0fcf654b9571c2459b6"><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="aes_8c.html#afcfa24a6132fa0fcf654b9571c2459b6">Nb</a> = 4</td></tr>
<tr class="memdesc:afcfa24a6132fa0fcf654b9571c2459b6"><td class="mdescLeft">&#160;</td><td class="mdescRight">状态包含的列(32-bit字)的个数。对于AES， Nb＝4 .  <a href="#afcfa24a6132fa0fcf654b9571c2459b6">更多...</a><br /></td></tr>
<tr class="separator:afcfa24a6132fa0fcf654b9571c2459b6"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a44909051db62133600cb826ba68fccca"><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="aes_8c.html#a44909051db62133600cb826ba68fccca">Nk</a></td></tr>
<tr class="memdesc:a44909051db62133600cb826ba68fccca"><td class="mdescLeft">&#160;</td><td class="mdescRight">密钥包含的 32-bit 字的个数。 对于该标准， Nk＝4,6 或 8.  <a href="#a44909051db62133600cb826ba68fccca">更多...</a><br /></td></tr>
<tr class="separator:a44909051db62133600cb826ba68fccca"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a7a14aa552991b97c25b8d9ff3c7d66e0"><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="aes_8c.html#a7a14aa552991b97c25b8d9ff3c7d66e0">Nr</a></td></tr>
<tr class="memdesc:a7a14aa552991b97c25b8d9ff3c7d66e0"><td class="mdescLeft">&#160;</td><td class="mdescRight">轮数，是 Nk 和 Nb(固定的)的函数。对于该标准， Nr＝10,12 或 14.  <a href="#a7a14aa552991b97c25b8d9ff3c7d66e0">更多...</a><br /></td></tr>
<tr class="separator:a7a14aa552991b97c25b8d9ff3c7d66e0"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a9f780d9aad33a38c6753b23246ba762d"><td class="memItemLeft" align="right" valign="top">uint8_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="aes_8c.html#a9f780d9aad33a38c6753b23246ba762d">R</a> [] = {0x02, 0x00, 0x00, 0x00}</td></tr>
<tr class="memdesc:a9f780d9aad33a38c6753b23246ba762d"><td class="mdescLeft">&#160;</td><td class="mdescRight">Generates the round constant Rcon[i].  <a href="#a9f780d9aad33a38c6753b23246ba762d">更多...</a><br /></td></tr>
<tr class="separator:a9f780d9aad33a38c6753b23246ba762d"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<h2 class="groupheader">函数说明</h2>
<a class="anchor" id="a3647794630b190782fc19e3d9b2be035"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void add_round_key </td>
          <td>(</td>
          <td class="paramtype">uint8_t *&#160;</td>
          <td class="paramname"><em>state</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">uint8_t *&#160;</td>
          <td class="paramname"><em>w</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">uint8_t&#160;</td>
          <td class="paramname"><em>r</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

</div>
</div>
<a class="anchor" id="a5d8ac3ac83810baa35fa15c5e4b25303"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void aes_cipher </td>
          <td>(</td>
          <td class="paramtype">uint8_t *&#160;</td>
          <td class="paramname"><em>in</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">uint8_t *&#160;</td>
          <td class="paramname"><em>out</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">uint8_t *&#160;</td>
          <td class="paramname"><em>w</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Performs the AES cipher operation. </p>
<dl class="params"><dt>参数</dt><dd>
  <table class="params">
    <tr><td class="paramname">*in</td><td>明文 </td></tr>
    <tr><td class="paramname">*out</td><td>加密后的密文 </td></tr>
    <tr><td class="paramname">*w</td><td>扩展后的密钥 </td></tr>
  </table>
  </dd>
</dl>
<dl class="retval"><dt>返回值</dt><dd>
  <table class="retval">
    <tr><td class="paramname"></td><td></td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a class="anchor" id="a5682ceb1811499fe30fbe705877ff32c"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">uint8_t* aes_init </td>
          <td>(</td>
          <td class="paramtype">size_t&#160;</td>
          <td class="paramname"><em>key_size</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Initialize AES variables and allocate memory for expanded key. </p>
<dl class="params"><dt>参数</dt><dd>
  <table class="params">
    <tr><td class="paramname">key_size</td><td>密钥的字节数 </td></tr>
  </table>
  </dd>
</dl>
<dl class="retval"><dt>返回值</dt><dd>
  <table class="retval">
    <tr><td class="paramname"></td><td></td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a class="anchor" id="a73d0f24db5e8c95eaf2b6c1979188b50"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void aes_inv_cipher </td>
          <td>(</td>
          <td class="paramtype">uint8_t *&#160;</td>
          <td class="paramname"><em>in</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">uint8_t *&#160;</td>
          <td class="paramname"><em>out</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">uint8_t *&#160;</td>
          <td class="paramname"><em>w</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Performs the AES inverse cipher operation. </p>
<dl class="params"><dt>参数</dt><dd>
  <table class="params">
    <tr><td class="paramname">*in</td><td>密文 </td></tr>
    <tr><td class="paramname">*out</td><td>密文的逆 </td></tr>
    <tr><td class="paramname">*w</td><td>扩展后的密钥 </td></tr>
  </table>
  </dd>
</dl>
<dl class="retval"><dt>返回值</dt><dd>
  <table class="retval">
    <tr><td class="paramname"></td><td></td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a class="anchor" id="a461739b060263bfe2888f4a47d8f5186"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void aes_key_expansion </td>
          <td>(</td>
          <td class="paramtype">uint8_t *&#160;</td>
          <td class="paramname"><em>key</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">uint8_t *&#160;</td>
          <td class="paramname"><em>w</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Key Expansion. </p>
<dl class="params"><dt>参数</dt><dd>
  <table class="params">
    <tr><td class="paramname">*key</td><td>密钥 </td></tr>
    <tr><td class="paramname">*w</td><td>密钥编排结果 </td></tr>
  </table>
  </dd>
</dl>
<dl class="retval"><dt>返回值</dt><dd>
  <table class="retval">
    <tr><td class="paramname"></td><td></td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a class="anchor" id="a4fd78e9e70a8fa25ffe7ac89c18d31a3"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void coef_add </td>
          <td>(</td>
          <td class="paramtype">uint8_t&#160;</td>
          <td class="paramname"><em>a</em>[], </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">uint8_t&#160;</td>
          <td class="paramname"><em>b</em>[], </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">uint8_t&#160;</td>
          <td class="paramname"><em>d</em>[]&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Addition of 4 byte words. </p>
<p>m(x) = x4+1 </p><dl class="params"><dt>参数</dt><dd>
  <table class="params">
    <tr><td class="paramname"></td><td>retval </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a class="anchor" id="a04aedb6d0c8e24c05e0f0ae089874229"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void coef_mult </td>
          <td>(</td>
          <td class="paramtype">uint8_t *&#160;</td>
          <td class="paramname"><em>a</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">uint8_t *&#160;</td>
          <td class="paramname"><em>b</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">uint8_t *&#160;</td>
          <td class="paramname"><em>d</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

</div>
</div>
<a class="anchor" id="a2a81402428c8f2be48e0cc40454164a0"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">uint8_t gadd </td>
          <td>(</td>
          <td class="paramtype">uint8_t&#160;</td>
          <td class="paramname"><em>a</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">uint8_t&#160;</td>
          <td class="paramname"><em>b</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Addition in GF(2^8) </p>

</div>
</div>
<a class="anchor" id="a589f455f9e9215c4328dd53f755bc839"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">uint8_t gsub </td>
          <td>(</td>
          <td class="paramtype">uint8_t&#160;</td>
          <td class="paramname"><em>a</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">uint8_t&#160;</td>
          <td class="paramname"><em>b</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Subtraction in GF(2^8) </p>

</div>
</div>
<a class="anchor" id="a4f1588573568532d6eee4ab5bab3da05"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void inv_mix_columns </td>
          <td>(</td>
          <td class="paramtype">uint8_t *&#160;</td>
          <td class="paramname"><em>state</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>逆列混合变换 </p>
<p>Transformation in the Inverse Cipher that is the inverse of MixColumns(). </p><dl class="params"><dt>参数</dt><dd>
  <table class="params">
    <tr><td class="paramname"></td><td>retval </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a class="anchor" id="a600ebfd9163919a2224440fc627bc659"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void inv_shift_rows </td>
          <td>(</td>
          <td class="paramtype">uint8_t *&#160;</td>
          <td class="paramname"><em>state</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>逆行移位变换 </p>
<p>Transformation in the Inverse Cipher that is the inverse of ShiftRows(). </p><dl class="params"><dt>参数</dt><dd>
  <table class="params">
    <tr><td class="paramname"></td><td>retval </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a class="anchor" id="a159a659a54feeb3f10ea6b9b458da4a3"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void inv_sub_bytes </td>
          <td>(</td>
          <td class="paramtype">uint8_t *&#160;</td>
          <td class="paramname"><em>state</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>逆字节替代变换 </p>
<p>Transformation in the Inverse Cipher that is the inverse of SubBytes(). </p><dl class="params"><dt>参数</dt><dd>
  <table class="params">
    <tr><td class="paramname"></td><td>retval </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a class="anchor" id="adb11e39050fc05e4546c825ca68d6eae"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void mix_columns </td>
          <td>(</td>
          <td class="paramtype">uint8_t *&#160;</td>
          <td class="paramname"><em>state</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>列混合变换 </p>
<p>Transformation in the Cipher that takes all of the columns of the State and mixes their data (independently of one another) to produce new columns. </p><dl class="params"><dt>参数</dt><dd>
  <table class="params">
    <tr><td class="paramname"></td><td>retval </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a class="anchor" id="a1ce5ff75f809a1788aa380e8a5c43bf2"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">uint8_t* Rcon </td>
          <td>(</td>
          <td class="paramtype">uint8_t&#160;</td>
          <td class="paramname"><em>i</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

</div>
</div>
<a class="anchor" id="a65c0ad6a1eef16ffa1c54cb0cb03f9b0"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void rot_word </td>
          <td>(</td>
          <td class="paramtype">uint8_t *&#160;</td>
          <td class="paramname"><em>w</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>对 4-byte 字进行循环移位 </p>
<p>Function used in the Key Expansion routine that takes a four-byte word and performs a cyclic permutation. </p><dl class="params"><dt>参数</dt><dd>
  <table class="params">
    <tr><td class="paramname">*w</td><td></td></tr>
  </table>
  </dd>
</dl>
<dl class="retval"><dt>返回值</dt><dd>
  <table class="retval">
    <tr><td class="paramname"></td><td></td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a class="anchor" id="a8887303a86f47615327ccb6ec6832bad"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void shift_rows </td>
          <td>(</td>
          <td class="paramtype">uint8_t *&#160;</td>
          <td class="paramname"><em>state</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>行移位变换 </p>
<p>Transformation in the Cipher that processes the State by cyclically shifting the last three rows of the State by different offsets. </p><dl class="params"><dt>参数</dt><dd>
  <table class="params">
    <tr><td class="paramdir">[out]</td><td class="paramname">*state</td><td></td></tr>
  </table>
  </dd>
</dl>
<dl class="retval"><dt>返回值</dt><dd>
  <table class="retval">
    <tr><td class="paramname"></td><td></td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a class="anchor" id="a26eb58cd12585e4469b85fe2c07d7e43"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void sub_bytes </td>
          <td>(</td>
          <td class="paramtype">uint8_t *&#160;</td>
          <td class="paramname"><em>state</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>字节替换 </p>
<p>Transformation in the Cipher that processes the State using a non­ linear byte substitution table (S-box) that operates on each of the State bytes independently. </p><dl class="params"><dt>参数</dt><dd>
  <table class="params">
    <tr><td class="paramname"></td><td>retval </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a class="anchor" id="a95c2f223af5c7bc9e20b501fa4c026e3"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void sub_word </td>
          <td>(</td>
          <td class="paramtype">uint8_t *&#160;</td>
          <td class="paramname"><em>w</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>对于 4 字节中的每一字节分别应用 S 盒 </p>
<p>Function used in the Key Expansion routine that takes a four-byte input word and applies an S-box to each of the four bytes to produce an output word. </p><dl class="params"><dt>参数</dt><dd>
  <table class="params">
    <tr><td class="paramname">*w</td><td></td></tr>
  </table>
  </dd>
</dl>
<dl class="retval"><dt>返回值</dt><dd>
  <table class="retval">
    <tr><td class="paramname"></td><td></td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<h2 class="groupheader">变量说明</h2>
<a class="anchor" id="a2689c4b3931025b79053532a5f1b0a85"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int K</td>
        </tr>
      </table>
</div><div class="memdoc">

<p>密码所使用的秘密密钥. </p>

</div>
</div>
<a class="anchor" id="afcfa24a6132fa0fcf654b9571c2459b6"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int Nb = 4</td>
        </tr>
      </table>
</div><div class="memdoc">

<p>状态包含的列(32-bit字)的个数。对于AES， Nb＝4 . </p>

</div>
</div>
<a class="anchor" id="a44909051db62133600cb826ba68fccca"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int Nk</td>
        </tr>
      </table>
</div><div class="memdoc">

<p>密钥包含的 32-bit 字的个数。 对于该标准， Nk＝4,6 或 8. </p>

</div>
</div>
<a class="anchor" id="a7a14aa552991b97c25b8d9ff3c7d66e0"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int Nr</td>
        </tr>
      </table>
</div><div class="memdoc">

<p>轮数，是 Nk 和 Nb(固定的)的函数。对于该标准， Nr＝10,12 或 14. </p>

</div>
</div>
<a class="anchor" id="a9f780d9aad33a38c6753b23246ba762d"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">uint8_t R[] = {0x02, 0x00, 0x00, 0x00}</td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Generates the round constant Rcon[i]. </p>

</div>
</div>
</div><!-- contents -->
</div><!-- doc-content -->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
  <ul>
    <li class="navelem"><a class="el" href="dir_afe89f749343fa812f00a025feac441b.html">exam</a></li><li class="navelem"><a class="el" href="dir_b795f7569447f4537a033ae9f8381a99.html">aes</a></li><li class="navelem"><a class="el" href="aes_8c.html">aes.c</a></li>
    <li class="footer">生成于 2022年 二月 16日 星期三 07:13:25 , 为 AES-API使用 
    <a href="http://www.doxygen.org/index.html">
    <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.8.7 </li>
  </ul>
</div>
</body>
</html>
